<template>
    <div class="common-layout">
        <el-container>
            <el-header style="background-color: bisque; padding: 20px;margin-bottom: 10px;">RBAC<span style="float: right;"><el-button type="danger" @click="out()">退出</el-button></span></el-header>
            <el-container>
                <el-aside width="200px">
                    <el-col :span="25">
                        <el-menu active-text-color="#ffd04b" router background-color="#545c64"
                            class="el-menu-vertical-demo" default-active="2" text-color="#fff" @open="handleOpen"
                            @close="handleClose"  :default-openeds="defaultOpeneds">
                            <el-sub-menu index="1" >
                                <template #title>
                                    <el-icon><location /></el-icon>
                                    <span>用户管理</span>
                                </template>
                                <el-menu-item index="Show">用户列表</el-menu-item>
                            </el-sub-menu>
                            <el-sub-menu index="1" >
                                <template #title>
                                    <el-icon>
                                        <location />
                                    </el-icon>
                                    <span>角色管理</span>
                                </template>
                                <el-menu-item  index="RoleShow" >角色列表</el-menu-item>
                            </el-sub-menu>
                            <el-sub-menu index="1" v-if="defaultProps.id!=3&&defaultProps.id!=7">
                                <template #title>
                                    <el-icon>
                                        <location />
                                    </el-icon>
                                    <span>菜单管理</span>
                                </template>
                                <el-menu-item index="MenuShow">菜单列表</el-menu-item>
                            </el-sub-menu>
                            <el-sub-menu index="1" v-if="defaultProps.id!=3&&defaultProps.id!=7">
                                <template #title>
                                    <el-icon>
                                        <location />
                                    </el-icon>
                                    <span>角色菜单关系管理</span>
                                </template>
                                <el-menu-item index="RoleMenuShow">角色菜单关系列表</el-menu-item>
                            </el-sub-menu>
                            <el-sub-menu index="1" v-if="defaultProps.id!=3&&defaultProps.id!=7">
                                <template #title>
                                    <el-icon>
                                        <location />
                                    </el-icon>
                                    <span>请假管理</span>
                                </template>
                                <el-menu-item index="LeaveShow">请假列表</el-menu-item>
                            </el-sub-menu>
                             <el-sub-menu index="1" v-if="defaultProps.id!=3&&defaultProps.id!=7">
                                <template #title>
                                    <el-icon>
                                        <location />
                                    </el-icon>
                                    <span>报表管理</span>
                                </template>
                                <el-menu-item index="ReportShow">报表列表</el-menu-item>
                            </el-sub-menu>
                            <el-sub-menu index="1">
                                <template #title>
                                    <el-icon>
                                        <location />
                                    </el-icon>
                                    <span>溯源管理</span>
                                </template>
                                <el-menu-item index="Traceability">溯源基本信息</el-menu-item>
                                <el-menu-item index="Details">溯源详情信息</el-menu-item>
                                <el-menu-item index="WinFrom">WinFrom窗体</el-menu-item>
                            </el-sub-menu>
                        </el-menu>
                    </el-col>
                </el-aside>
                <el-main><router-view></router-view></el-main>
            </el-container>
        </el-container>
    </div>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const router = useRouter();
const activeIndex=ref('1');
const defaultOpeneds=ref(['1'])
import {
    Document,
    Menu as IconMenu,
    Location,
    Setting,
} from '@element-plus/icons-vue'
import { onMounted, ref } from 'vue';

const handleOpen = (key: string, keyPath: string[]) => {
    console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
    console.log(key, keyPath)
}
const out=()=>{
    router.push('/')
}
const defaultProps:any=ref({
    id:0
})
//获取角色id
const getroleid=()=>{
defaultProps.value.id=localStorage.getItem("roleId");
console.log(defaultProps.value.id);
}
onMounted(()=>{
    getroleid();
})
</script>